package com.shire.shire_interface.constants;

import com.shire.shire_interface.common.utils.KeyValue;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class IphoneConfigItem {
    private int rate;
    private String name;
    private List<KeyValue<String, Integer>> osversions = new ArrayList<KeyValue<String,Integer>>();

    public IphoneConfigItem(){}

    public String getOsVersion(){
        int rand = new Random().nextInt(100);
        for(KeyValue<String, Integer> kv : osversions){
            if(rand<=kv.getValue()){
                return kv.getKey();
            }
            rand -= kv.getValue();
        }
        return null;
    }

    public int getRate() {
        return rate;
    }
    public void setRate(int rate) {
        this.rate = rate;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public List<KeyValue<String, Integer>> getOsversions() {
        return osversions;
    }
    public void setOsversions(List<KeyValue<String, Integer>> osversions) {
        this.osversions = osversions;
    }
}
